<?php
require_once("DBC2.php");

    //region user methods
        function User_Auth($user,$pass)
        {   //global $DBC;

            return ExecuteScalar2("SELECT id as id FROM users WHERE USER='"
            .$user."' AND pass='"
            .$pass."';");
        }

		function Logger($direction,$timestamp,$user_agent,$content_lenght,$body_in,$body_out)
		{ 
			
		$mysql = new mysql();
		$mysql->connect();  
		
		
			if($direction==1)
		{
  			  $sql="INSERT INTO `clcs_flickr`.`logs_incoming`(`id`,`timestamp`,`user_agent`,`content_lenght`,`body`)". 
				" VALUES ( NULL,".$timestamp.",".
				mysql_real_escape_string($user_agent).",".
				$content_lenght.",".
				mysql_real_escape_string($body_in).");";
	}
	
	else
	{
	$sql="INSERT INTO `clcs_flickr`.`logs_outgoing`(`id`,`timestamp`,`request_body`,`responce_body`)".
	" VALUES ( NULL,".$timestamp.",".mysql_real_escape_string($body_in).",".mysql_real_escape_string($body_out).");";
	}
	
	
	$result=$mysql->query($sql); 
	return  $result;
	
}
		
		
        function EndPoint_Php($acc_id,$token,$code)
        { 
          if (IsValidSession($acc_id,$token))
          { 
               $file_adr=$_SERVER['DOCUMENT_ROOT']."/soap/data/".$acc_id."_".$token.".php";
			$handel=fopen($file_adr,"x+");
            fwrite( $handel,$code);
            fclose($handel);

				$ch = curl_init("http://clcs.ro/soap/data/".$acc_id."_".$token.".php");
				curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
				curl_setopt($ch, CURLOPT_HEADER,false);
	
				$html=curl_exec($ch);
				curl_close($ch);
				
			 unlink($file_adr);	
				
		  }  
			  return $html;

        }

?>